<?php

class Home extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		$this->load->model('advertise_m');
		$this->load->model('visitors_m');
		$this->_get_ip();
	}
	function _get_ip(){
		
		$ip = "";
		
		if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)){
           $ip =  $_SERVER["HTTP_X_FORWARDED_FOR"];  
        }else if (array_key_exists('REMOTE_ADDR', $_SERVER)) { 
             $ip =  $_SERVER["REMOTE_ADDR"]; 
        }else if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
             $ip =  $_SERVER["HTTP_CLIENT_IP"]; 
        } 
		
		$res = $this->visitors_m->add_visitor( $ip );
        
	}// end get ip
	
	function index(){
		// since this is a frontpage we only get the advertisements with a blank location..
		$adds = $this->advertise_m->get_adds_location('index');
		
		$data = array(
			'title' => 'REGFINDER | HOME PAGE',
			'adds' => $adds
		);
		
		$this->load->view('frontend/includes/header.php',$data);
		$this->load->view('frontend/home.php',$data);
		$this->load->view('frontend/includes/footer.php',$data);
	
	}

}// end frontend..